import 'package:ati_package/core/extension/ati_widgets_extension.dart';
import 'package:ati_package/core/utils/ati_assets.dart';
import 'package:ati_package/core/utils/ati_enum.dart';
import 'package:ati_package/core/utils/ati_font.dart';
import 'package:ati_package/pages/common/ati_scaffold.dart';
import 'package:ati_package/pages/common/widgets/ati_dialogs.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class TrendSettingView extends StatefulWidget {
  const TrendSettingView({super.key});

  @override
  State<TrendSettingView> createState() => _TrendSettingViewState();
}

class _TrendSettingViewState extends State<TrendSettingView> {
  @override
  Widget build(BuildContext context) {
    return AtiScaffold(
      title: '隐私设置',
      body: ListView(
        children: [
          _buildItem(AtiSetModel.setCover, '修改封面'),
          _buildItem(AtiSetModel.setDayRange, '允许朋友查看动态的范围'),
        ],
      ),
    );
  }

  _buildItem(AtiSetModel setModel, String titleStr) {
    return Container(
      height: 46.r,
      margin: EdgeInsets.only(left: 16.r, top: 10.r, right: 16.r),
      padding: EdgeInsets.symmetric(horizontal: 16.r),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.r),
      ),
      child: Row(
        children: [
          Text(titleStr, style: TextStyle(fontSize: AtiFont.font12)),
          Spacer(),
          ...[
            if (setModel == AtiSetModel.setDayRange)
              Text(
                '近3个月',
                style: TextStyle(
                  fontSize: AtiFont.font12,
                  color: Color(0xFF666666),
                ),
              ),
            SizedBox(width: 2.r),
            Image.asset(
              width: 14.r,
              height: 14.r,
              AtiAssets.atiNextIcon,
              package: 'ati_package',
            ),
          ],
        ],
      ),
    ).addTapGesture(
      onTap: () {
        switch (setModel) {
          case AtiSetModel.setCover:
            {}
            break;
          case AtiSetModel.setDayRange:
            {
              AtiDialog.bottomListBottomSheet(
                titleStr: '选择天数',
                dataList: ['3', '15', '30'],
                tapBack: () {},
              );
            }
            break;
          case AtiSetModel.clearCache:
            // TODO: Handle this case.
            throw UnimplementedError();
          case AtiSetModel.deleteAccount:
            // TODO: Handle this case.
            throw UnimplementedError();
        }
      },
    );
  }
}
